Skip to content

aspose-ocr-cloud/aspose-ocr-cloud-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aspose.OCR Cloud for Java SDK 23.12.0

License Nuget

Aspose.OCR Cloud is an optical character recognition as a service. With it, you can easily add OCR functionality to almost any device or platform, including netbooks, mini PCs, or even entry-level smartphones.

Our engine can read text from images, photos, screenshots and scanned PDFs in a wide variety of European, Cyrillic and Oriental fonts, returning results in the most popular document formats. Powerful built-in image processing filters based on neural networks automatically correct skewed and distorted images, automatically remove dirt, smudges, scratches, glare and other image defects that can affect recognition accuracy. To further improve the results, Aspose.OCR Cloud has a built-in spell checker that automatically replaces misspelled words and saves you the trouble of manually correcting the recognition results.

Even the complex recognition tasks can be done with a couple of API calls. To make interacting with Aspose.OCR Cloud services from .NET applications even easier, we provide the software development kit (SDK) for .NET. It handles all the routine operations such as establishing connections, sending API requests, and parsing responses, wrapping all these tasks into a few simple classes.

Aspose.OCR Cloud SDK for .NET is open source under the MIT license. You can freely use it for any projects, including commercial and proprietary applications, as well as modify any part of its code.

Try Online

Image to Text Image to Searchable PDF PDF OCR Receipt Scanner
Scan Image Image to Searchable PDF PDF OCR Receipt Scanner

What was changed in version 23.12.0

A summary of recent changes, enhancements and bug fixes in Aspose.OCR Cloud SDK for Java 23.12.0 release:

Key Summary Category
OCR‑3737 Added a free API for evaluating image recognition without authorization.
Some restrictions apply. See below for details.
New feature

Added public APIs:

The following public APIs have been introduced in this release:

Image recognition evaluation

The following new classes have been added:

Class Description
RecognizeImageTrialApi Image recognition API that works without authorization.

Important: In recognition results, 10% of the words are substituted with asterisks (*). The sequence of masked words remains unchanged upon re-submitting the identical image for recognition.

Learn more...

Updated public APIs:

No changes

Removed public APIs:

No changes.

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.aspose</groupId>
  <artifactId>aspose-ocr-cloud</artifactId>
  <version>23.12.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral()     // Needed if the 'aspose-ocr-cloud' jar has been published to maven central.
    mavenLocal()       // Needed if the 'aspose-ocr-cloud' jar has been published to the local maven repo.
  }

  dependencies {
     implementation "com.aspose:aspose-ocr-cloud:23.12.0"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/aspose-ocr-cloud-23.12.0.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

package org.example;

import Aspose.OCR.Cloud.SDK.RecognizeImageTrialApi;
import Aspose.OCR.Cloud.SDK.model.*;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;

public class RecognizeImageTrialExample {

    public static void run() {
        try {
            RecognizeImageTrialApi api = new RecognizeImageTrialApi();
            OCRSettingsRecognizeImage settings = new OCRSettingsRecognizeImage();
            settings.setLanguage(Language.ENGLISH);
            settings.setDsrConfidence(DsrConfidence.DEFAULT);
            settings.setDsrMode(DsrMode.NODSRNOFILTER);
            settings.setMakeBinarization(false);
            settings.setMakeSkewCorrect(false);
            settings.setMakeContrastCorrection(false);
            settings.setMakeUpsampling(false);
            settings.setResultType(ResultType.TEXT);

            String imageFileName = "samples\\latin.png";
            byte[] imageData = Files.readAllBytes(Path.of(imageFileName));

            OCRRecognizeImageBody requestBody = new OCRRecognizeImageBody();
            requestBody.setImage(imageData);
            requestBody.setSettings(settings);

            System.out.println("Sending sample image (" + imageFileName +") to RecognizeImageTrialApi...");
            String taskId = api.postRecognizeImageTrial(requestBody);

            System.out.println("File successfully sent. " +
                    "Your task ID is " + taskId + "\nGetting task results...");
            OCRResponse apiResponse = api.getRecognizeImageTrial(taskId);

            String fileExtension = "";
            switch(apiResponse.getResults().get(0).getType()) {
                case "Text":
                    fileExtension = "txt";
                    break;
                default:
                    fileExtension = "txt";
            };
            String resultFileName = "results\\" + apiResponse.getId() + "." + fileExtension;
            Files.createDirectories(Paths.get("results"));
            Files.write(Path.of(resultFileName), apiResponse.getResults().get(0).getData());

            System.out.println(new String(apiResponse.getResults().get(0).getData(), StandardCharsets.UTF_8) + "\n\n");
            System.out.println("Respose received with status " + apiResponse.getTaskStatus().getValue() +"\n\n" +
                    "Your results saved to " + resultFileName + "\n\n" +
                    "Press any key to continue\n");

            System.in.read();
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }
}

Running demo

  1. Open Examples demo project.
  2. Provide your Client ID and Client Secret (see Authorization above).
  3. Run the project.

Authorization

Aspose.OCR Cloud follows industry standards and best practices to keep your data secure. All communication with OCR REST API is done using JWT authentication, which provides an open-standard, highly secure way to exchange information. Time-limited JWT tokens are generated using Client ID and Client Secret credentials that are specific for each application. To obtain the credentials:

  1. Sign in to Aspose Cloud API Dashboard.

  2. Go to Applications page.

  3. Click Create New Application button.

  4. Give the application an easily recognizable name so it can be quickly found in a long list, and provide an optional detailed description.

  5. Create the cloud storage by clicking the plus icon and following the required steps. You can also reuse existing storage, if available.
    Aspose.OCR Cloud uses its own internal storage, so you can provide the bare minimum storage options:

    • Type: Internal storage
    • Storage name: Any name you like
    • Storage mode: Retain files for 24 hours
  6. Click Save button.

  7. Click the newly created application and copy the values from Client Id and Client Secret fields.

  8. Pass in the values from the Client ID and Client Secret fields when initializing the required OCR API.

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
BinarizeImageApi cancelBinarizeImage DELETE /v5.0/ocr/BinarizeImage CancelBinarizeImage
BinarizeImageApi getBinarizeImage GET /v5.0/ocr/BinarizeImage GetBinarizeImage
BinarizeImageApi postBinarizeImage POST /v5.0/ocr/BinarizeImage PostBinarizeImage
ConvertTextToSpeechApi cancelConvertTextToSpeech DELETE /v5.0/ocr/ConvertTextToSpeech CancelConvertTextToSpeech
ConvertTextToSpeechApi getConvertTextToSpeech GET /v5.0/ocr/ConvertTextToSpeech GetConvertTextToSpeech
ConvertTextToSpeechApi postConvertTextToSpeech POST /v5.0/ocr/ConvertTextToSpeech PostConvertTextToSpeech
ConvertTextToSpeechTrialApi cancelConvertTextToSpeechTrial DELETE /v5.0/ocr/ConvertTextToSpeechTrial CancelConvertTextToSpeechTrial
ConvertTextToSpeechTrialApi getConvertTextToSpeechTrial GET /v5.0/ocr/ConvertTextToSpeechTrial GetConvertTextToSpeechTrial
ConvertTextToSpeechTrialApi postConvertTextToSpeechTrial POST /v5.0/ocr/ConvertTextToSpeechTrial PostConvertTextToSpeechTrial
DeskewImageApi cancelDeskewImage DELETE /v5.0/ocr/DeskewImage CancelDeskewImage
DeskewImageApi getDeskewImage GET /v5.0/ocr/DeskewImage GetDeskewImage
DeskewImageApi postDeskewImage POST /v5.0/ocr/DeskewImage PostDeskewImage
DetectRegionsApi cancelDetectRegions DELETE /v5.0/ocr/DetectRegions CancelDetectRegions
DetectRegionsApi getDetectRegions GET /v5.0/ocr/DetectRegions GetDetectRegions
DetectRegionsApi postDetectRegions POST /v5.0/ocr/DetectRegions PostDetectRegions
DewarpImageApi cancelDewarpImage DELETE /v5.0/ocr/DewarpImage CancelDewarpImage
DewarpImageApi getDewarpImage GET /v5.0/ocr/DewarpImage GetDewarpImage
DewarpImageApi postDewarpImage POST /v5.0/ocr/DewarpImage PostDewarpImage
DjVu2PdfApi cancelDjVu2PDF DELETE /v5.0/ocr/DjVu2PDF CancelDjVu2PDF
DjVu2PdfApi getDjVu2PDF GET /v5.0/ocr/DjVu2PDF GetDjVu2PDF
DjVu2PdfApi postDjVu2PDF POST /v5.0/ocr/DjVu2PDF PostDjVu2PDF
IdentifyFontApi cancelIdentifyFont DELETE /v5.0/ocr/IdentifyFont CancelIdentifyFont
IdentifyFontApi getIdentifyFont GET /v5.0/ocr/IdentifyFont GetIdentifyFont
IdentifyFontApi postIdentifyFont POST /v5.0/ocr/IdentifyFont PostIdentifyFont
ImageProcessingApi getResultFile GET /v5.0/ocr/ImageProcessing/GetResultFile GetResultFile
ImageProcessingApi getResultTask GET /v5.0/ocr/ImageProcessing/GetResultTask GetResultTask
ImageProcessingApi postBinarizationFile POST /v5.0/ocr/ImageProcessing/PostBinarizationFile PostBinarizationFile
ImageProcessingApi postDewarpingFile POST /v5.0/ocr/ImageProcessing/PostDewarpingFile PostDewarpingFile
ImageProcessingApi postSkewCorrectionFile POST /v5.0/ocr/ImageProcessing/PostSkewCorrectionFile PostSkewCorrectionFile
ImageProcessingApi postUpsamplingFile POST /v5.0/ocr/ImageProcessing/PostUpsamplingImageFile PostUpsamplingImageFile
RecognizeAndParseInvoiceApi cancelRecognizeAndParseInvoice DELETE /v5.0/ocr/RecognizeAndParseInvoice CancelRecognizeAndParseInvoice
RecognizeAndParseInvoiceApi getRecognizeAndParseInvoice GET /v5.0/ocr/RecognizeAndParseInvoice GetRecognizeAndParseInvoice
RecognizeAndParseInvoiceApi postRecognizeAndParseInvoice POST /v5.0/ocr/RecognizeAndParseInvoice PostRecognizeAndParseInvoice
RecognizeImageApi cancelRecognizeImage DELETE /v5.0/ocr/RecognizeImage CancelRecognizeImage
RecognizeImageApi getRecognizeImage GET /v5.0/ocr/RecognizeImage GetRecognizeImage
RecognizeImageApi postRecognizeImage POST /v5.0/ocr/RecognizeImage PostRecognizeImage
RecognizeImageTrialApi cancelRecognizeImageTrial DELETE /v5.0/ocr/RecognizeImageTrial CancelRecognizeImageTrial
RecognizeImageTrialApi getRecognizeImageTrial GET /v5.0/ocr/RecognizeImageTrial GetRecognizeImageTrial
RecognizeImageTrialApi postRecognizeImageTrial POST /v5.0/ocr/RecognizeImageTrial PostRecognizeImageTrial
RecognizeLabelApi cancelRecognizeLabel DELETE /v5.0/ocr/RecognizeLabel CancelRecognizeLabel
RecognizeLabelApi getRecognizeLabel GET /v5.0/ocr/RecognizeLabel GetRecognizeLabel
RecognizeLabelApi postRecognizeLabel POST /v5.0/ocr/RecognizeLabel PostRecognizeLabel
RecognizePdfApi cancelRecognizePdf DELETE /v5.0/ocr/RecognizePdf CancelRecognizePdf
RecognizePdfApi getRecognizePdf GET /v5.0/ocr/RecognizePdf GetRecognizePdf
RecognizePdfApi postRecognizePdf POST /v5.0/ocr/RecognizePdf PostRecognizePdf
RecognizeReceiptApi cancelRecognizeReceipt DELETE /v5.0/ocr/RecognizeReceipt CancelRecognizeReceipt
RecognizeReceiptApi getRecognizeReceipt GET /v5.0/ocr/RecognizeReceipt GetRecognizeReceipt
RecognizeReceiptApi postRecognizeReceipt POST /v5.0/ocr/RecognizeReceipt PostRecognizeReceipt
RecognizeRegionsApi cancelRecognizeRegions DELETE /v5.0/ocr/RecognizeRegions CancelRecognizeRegions
RecognizeRegionsApi getRecognizeRegions GET /v5.0/ocr/RecognizeRegions GetRecognizeRegions
RecognizeRegionsApi postRecognizeRegions POST /v5.0/ocr/RecognizeRegions PostRecognizeRegions
RecognizeTableApi cancelRecognizeTable DELETE /v5.0/ocr/RecognizeTable CancelRecognizeTable
RecognizeTableApi getRecognizeTable GET /v5.0/ocr/RecognizeTable GetRecognizeTable
RecognizeTableApi postRecognizeTable POST /v5.0/ocr/RecognizeTable PostRecognizeTable
TextToSpeechApi getTextToSpeechResult GET /v5.0/ocr/TextToSpeech/GetTextToSpeechResult GetTextToSpeechResult
TextToSpeechApi getTextToSpeechResultFile GET /v5.0/ocr/TextToSpeech/GetTextToSpeechResultFile GetTextToSpeechResultFile
TextToSpeechApi postTextToSpeech POST /v5.0/ocr/TextToSpeech/PostTextToSpeech PostTextToSpeech
UpscaleImageApi cancelUpscaleImage DELETE /v5.0/ocr/UpscaleImage CancelUpscaleImage
UpscaleImageApi getUpscaleImage GET /v5.0/ocr/UpscaleImage GetUpscaleImage
UpscaleImageApi postUpscaleImage POST /v5.0/ocr/UpscaleImage PostUpscaleImage
UtilitiesApi getTaskStatus GET /v5.0/ocr/Utilities/GetTaskStatus GetTaskStatus

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

JWT

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes: N/A

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

About

Aspose OCR Cloud Java SDK is a simple OCR technology, which you can use in your application to convert image to text.

Resources

Stars

Watchers

Forks

Packages

No packages published